package com.zhl.util3;

import java.util.Random;

public class MyUtil {

    //进行私有  则无法实例化 进行new调用。
    private MyUtil(){

    }
    public static String createCode(int length){
        String randomCode = "";
        String allChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

        Random random = new Random();
        //产生随机验证码
        for (int i = 0; i < length; i++) {
            int index = random.nextInt(allChars.length());
            randomCode += allChars.charAt(index);
        }
        return randomCode;
    }
}
